Expose X-Modified-At via CORS for module reads#32
Merged
Conversation
ModuleRoute already sets the header on GET responses (and ModuleFlowTest pins its presence). Cross-origin browsers can't read it without Access-Control-Expose-Headers, so octi-web's cross-origin fetch saw it as null. octi-web's multi-connector merge orders peer data by newest X-Modified-At per (deviceId, moduleId). Without this exposure, the merge falls back to deterministic-tiebreak in production while still working in dev (where same-origin or localhost relaxes the restriction). Sister web change: d4rken-org/octi-web#21.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
X-Modified-AttoAccess-Control-Expose-Headersso cross-origin browsers can read the header thatModuleRoutealready sets onGET/v1/module/{moduleId}.ModuleFlowTestandModuleMigrationTestalready pin that the header is sent.CorsFlowTestpins which headers are exposed cross-origin — this PR adds the new entry to that list.Why
octi-web's multi-connector merge orders peer data by newest
X-Modified-Atper(deviceId, moduleId). Without CORS exposure,response.headers.get("X-Modified-At")returnsnullfor the deployed cross-origin client (web.octi.darken.eu→prod.kserver.octi.darken.eu), and the merge falls back to a deterministic tiebreak onconnectorIdonly — semantically arbitrary.This unblocks the multi-connector port on web. Same-origin / localhost dev was unaffected (CORS doesn't strip headers there).
Sister PR
X-Modified-At; this server PR makes it actually visible cross-origin.Test plan
./gradlew test --tests "eu.darken.octi.server.common.CorsFlowTest"— green (assertsx-modified-atis now inAccess-Control-Expose-Headers)./gradlew test --tests "eu.darken.octi.server.module.ModuleFlowTest" --tests "eu.darken.octi.server.module.ModuleMigrationTest"— green (header still set on responses)